package com.iflytek.universitymanagement.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration
public class InterceptorConfig extends WebMvcConfigurationSupport {


    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor())  //配置jwt的拦截器
                .addPathPatterns("/**")   //拦截所有的请求路径
                .excludePathPatterns("/login1");

        super.addInterceptors(registry);
    }

    @Bean(name = "customJwtInterceptor")
    public HandlerInterceptor jwtInterceptor() {
        return new JwtInterceptor();
    }
}
